package com.tosmart.jorm.models.oracle;

import com.tosmart.jorm.annotation.*;
import com.tosmart.jorm.models.Family;

import java.io.Serializable;
import java.util.Date;

/**
 * @author tosmart@gmail.com
 */
@JormEntity(table = "PEOPLE")
public class PersonSequenceGenId implements Serializable {

    public PersonSequenceGenId() {
    }

    public PersonSequenceGenId(int id) {
        this.id = id;
    }

    public Date getBirth() {
        return birth;
    }

    public void setBirth(Date birth) {
        this.birth = birth;
    }

    public Family getFamily() {
        return family;
    }

    public int getFamilyId() {
        return familyId;
    }

    public void setFamilyId(int familyId) {
        this.familyId = familyId;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    @Override
    public String toString() {
        final StringBuffer sb = new StringBuffer();
        sb.append("Person");
        sb.append("{birth=").append(birth);
        sb.append(", id=").append(id);
        sb.append(", name='").append(name).append('\'');
        sb.append(", sex='").append(sex).append('\'');
        sb.append(", familyId=").append(familyId);
        sb.append(", family=").append(family);
        sb.append('}');
        return sb.toString();
    }

    @JormMap(
            primaryKey = true,
            autoGenerate = GenerateMethod.Sequence,
            oracleSequence = "SEQ_PERSON_ID"
    )
    private int id;
    @JormMap
    private String name;
    @JormMap
    private String sex;
    @JormMap
    private Date birth;
    @JormMap(column = "FAMILY_ID")
    private int familyId;

    @JormRefer(foreignKeys = "FAMILY_ID")
    private Family family = null;
}